﻿namespace TriangleGames.TrainRes
{
    using System;
    using UnityEngine;

    [Serializable]
    public class NamedVariable : INameable, INamedVariable
    {
        [SerializeField]
        private string name;
        [SerializeField]
        private bool networkSync;
        [SerializeField]
        private bool showInInspector;
        [SerializeField]
        private string tooltip;
        [SerializeField]
        private bool useVariable;

        public NamedVariable()
        {
            this.tooltip = "";
            this.name = "";
            this.tooltip = "";
        }

        public NamedVariable(NamedVariable source)
        {
            this.tooltip = "";
            if (source != null)
            {
                this.useVariable = source.useVariable;
                this.name = source.name;
                this.showInInspector = source.showInInspector;
                this.tooltip = source.tooltip;
                this.networkSync = source.networkSync;
            }
        }

        public NamedVariable(string name)
        {
            this.tooltip = "";
            this.name = name;
            if (!string.IsNullOrEmpty(name))
            {
                this.useVariable = true;
            }
        }

        public bool IsNone
        {
            get
            {
                return (this.useVariable && string.IsNullOrEmpty(this.name));
            }
        }

        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.name = value;
            }
        }

        public bool NetworkSync
        {
            get
            {
                return this.networkSync;
            }
            set
            {
                this.networkSync = value;
            }
        }

        public bool ShowInInspector
        {
            get
            {
                return this.showInInspector;
            }
            set
            {
                this.showInInspector = value;
            }
        }

        public string Tooltip
        {
            get
            {
                return this.tooltip;
            }
            set
            {
                this.tooltip = value;
            }
        }

        public bool UseVariable
        {
            get
            {
                return this.useVariable;
            }
            set
            {
                this.useVariable = value;
            }
        }
    }
}

